/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.view.symbols;

import org.jfonia.assets.fonts.Fughetta;
import org.jfonia.connect5.basics.MutableValueNode;
import org.jfonia.connect5.basics.ValueNode;
import org.jfonia.connect5.basics.Observer;
import org.jfonia.constants.SymbolConstants;
import org.jfonia.constants.ViewConstants;

/**
 *
 * @author Rik Bauwens
 */
public class NoteHeadSymbol extends PrimitiveStaffSymbol
{
        public NoteHeadSymbol(ValueNode<Double> frameX, ValueNode<Double> staffY,
                              MutableValueNode<Double> staffBase, MutableValueNode<Double> postStaffBase,
                              ValueNode<Double> xNode, MutableValueNode<Double> widthNode,
                              MutableValueNode<Integer> rankNode, ValueNode<Integer> noteHeadNode)
        {
                super(frameX, staffY, staffBase, postStaffBase, xNode, widthNode, rankNode);
                init(noteHeadNode);
        }
    
        private void init(ValueNode<Integer> noteHeadNode)
        {
                //NoteHead
                setNoteHead(noteHeadNode.getValue());

                noteHeadNode.addObserver(new Observer()
                {
                        public void onNotify(Object source)
                        {
                                setNoteHead(((ValueNode<Integer>) source).getValue());
                        }
                });
                
        }

        private void setNoteHead(int noteHeadId)
        {
                /*if(noteHeadId == SymbolConstants.NOTEHEAD_BREVE
                        || noteHeadId == SymbolConstants.NOTEHEAD_SEMIBREVE)
                        textGlyph = Fughetta.getGlyph(SymbolConstants.NOTEHEAD_1);
                else if(noteHeadId == SymbolConstants.NOTEHEAD_MINIM)
                        textGlyph = Fughetta.getGlyph(SymbolConstants.NOTEHEAD_1_2);
                else if(noteHeadId == SymbolConstants.NOTEHEAD_CROTCHET
                        || noteHeadId == SymbolConstants.NOTEHEAD_QUAVER
                        || noteHeadId == SymbolConstants.NOTEHEAD_SEMIQUAVER
                        || noteHeadId == SymbolConstants.NOTEHEAD_DEMISEMIQUAVER
                        || noteHeadId == SymbolConstants.NOTEHEAD_HEMIDEMISEMIQUAVER
                        *//*|| noteHeadId == SymbolConstants.NOTEHEAD_QUASIHEMIDEMISEMIQUAVER*///)
                        //textGlyph = Fughetta.getGlyph(SymbolConstants.NOTEHEAD_1_4);
                if(noteHeadId == ViewConstants.NOTEHEAD1)
                        textGlyph = Fughetta.getGlyph(SymbolConstants.NOTEHEAD_1);
                else if(noteHeadId == ViewConstants.NOTEHEAD1_2)
                        textGlyph = Fughetta.getGlyph(SymbolConstants.NOTEHEAD_1_2);
                else if(noteHeadId == ViewConstants.NOTEHEAD1_4)
                        textGlyph = Fughetta.getGlyph(SymbolConstants.NOTEHEAD_1_4);
                textGlyph.setSize(SymbolConstants.SYMBOL_SIZE);
                updateNodes();
        }
}
